package com.baoteng.rbspy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

//(exclude = MybatisAutoConfiguration.class)
@ComponentScan({ "com.baoteng.**" })
@EnableScheduling
@SpringBootApplication
public class MainApplication extends SpringBootServletInitializer {

	@SuppressWarnings("unused")
	private static final Logger logger = LoggerFactory.getLogger(MainApplication.class);

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(MainApplication.class);
	}
	
	@SuppressWarnings("unused")
	public static void main(String[] args) throws InterruptedException {
//		SpringApplication.run(MainApplication.class,args);
		SpringApplication springApplication = new SpringApplication(MainApplication.class);
		springApplication.setBannerMode(Banner.Mode.OFF);
//		springApplication.run(args);
		ApplicationContext ctx = springApplication.run(args);
//		LoginHolder loginHolder = (LoginHolder)ctx.getBean("loginHolder");
//		loginHolder.vpnLogin();
//		int counter=0;
//		while(true) {
//			if(loginHolder.checkVpnOnline() || counter>10) {
//				break;
//			}
//			counter++;
//			Thread.sleep(1*1000);
//		}
		
//		OkHttpClientService client = (OkHttpClientService)ctx.getBean("okHttpClientService");
//		if(!client.login()) {
//			logger.info("*******************【登陆业务核心系统失败】********************");
//			System.exit(0);
//		}
//		if(!client.carlogin()) {
//			logger.info("*******************【登陆车险系统失败】********************");
//			System.exit(0);
//		}
//		if(!client.ciflogin()) {
//			logger.info("*******************【登陆CRM系统失败】********************");
//			System.exit(0);
//		}
//		if(!client.cbclogin()){
//			logger.info("*******************【登陆CRM系统失败】********************");
//			System.exit(0);
//		}
	}
}
